#pragma once

class ATL_NO_VTABLE CPanicButtonEventSink:
	public CComObjectRootEx<CTestClientThreadModel>,
	public CComCoClass<CPanicButtonEventSink, &CLSID_PanicButtonEventSink>,
	public IDispatchImpl<DPanicButtonEvents, &IID_DPanicButtonEvents, &LIBID_PanicButtonLib, 1, 0>,
	public IDispatchImpl<IPanicButtonEventSink, &IID_IPanicButtonEventSink, &LIBID_TestClientLib, 1, 0>
{
public:

	inline CPanicButtonEventSink( ) {
		debug( L"CPanicButtonEventSink::`ctor\n" );
		hwndNotify = nullptr;
	}

	inline virtual ~CPanicButtonEventSink( ) {
		debug( L"CPanicButtonEventSink::`dtor\n" );
	}

	DECLARE_REGISTRY_RESOURCEID( IDR_PANICBUTTONEVENTSINK )

	BEGIN_COM_MAP( CPanicButtonEventSink )
		COM_INTERFACE_ENTRY( IDispatch )
		COM_INTERFACE_ENTRY( DPanicButtonEvents )
		COM_INTERFACE_ENTRY( IPanicButtonEventSink )
	END_COM_MAP( )

	DECLARE_PROTECT_FINAL_CONSTRUCT( )

	inline HRESULT FinalConstruct( ) {
		debug( L"CPanicButtonEventSink::FinalConstruct\n" );
		return S_OK;
	}

	inline void FinalRelease( ) {
		debug( L"CPanicButtonEventSink::FinalRelease\n" );
	}

	//
	// DPanicButtonEvents
	//

public:

	STDMETHOD_( void, LidStatusChange )( VARIANT_BOOL LidOpen );
	STDMETHOD_( void, ButtonStatusChange )( VARIANT_BOOL ButtonPressed );

	//
	// IPanicButtonEventSink
	//

public:

	STDMETHOD( put_NotifyWindow )( IN HWND hwndNotify );
	STDMETHOD( get_NotifyWindow )( OUT HWND* phwndNotify );

	//
	// Implementation
	//

private:

	HWND hwndNotify;

};

OBJECT_ENTRY_AUTO( __uuidof( PanicButtonEventSink ), CPanicButtonEventSink )
